//
//  LEStaffCell.m
//  LoveExpressBusiness
//
//  Created by 刘甲奇 on 2017/5/10.
//  Copyright © 2017年 DFH. All rights reserved.
//

#import "LEStaffCell.h"
#import "UIImageView+WebCache.h"

@interface LEStaffCell()
@property (weak, nonatomic) IBOutlet UIImageView *avatorImage;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *phoneLabel;
@property (weak, nonatomic) IBOutlet UIButton *fireButton;
@property (weak, nonatomic) IBOutlet UIButton *changeRoleButton;

/**
 <#Description#>
 */
@property(nonatomic,strong)staffCellBlock block;

@end

@implementation LEStaffCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (void)setModel:(LEStaffModel *)model
{
    [self setData:model];
}
- (void)setCheckModel:(LEStaffModel *)model
{
    [self setData:model];
    [self.fireButton setTitle:@"通过" forState:0];
    [self.changeRoleButton setTitle:@"不通过" forState:0];
}
- (void)setUnpassedModel:(LEStaffModel *)model
{
    [self setData:model];
    [self.fireButton setHidden:YES];
    [self.changeRoleButton setHidden:YES];
}
#pragma mark- privateMethod
- (void)setData:(LEStaffModel *)model
{
    _model = model;
    self.nameLabel.text = model.service_truename;
    self.phoneLabel.text = [NSString stringWithFormat:@"手机:%@",model.service_telphone];
    [self.avatorImage sd_setImageWithURL:[NSURL URLWithString:model.s_portrait]];
    if ([model.service_place isEqualToString:@"1"]) {
        [self.changeRoleButton setTitle:@"转为派送服务" forState:0];
    }
    if ([model.service_place isEqualToString:@"2"]) {
        [self.changeRoleButton setTitle:@"转为店内服务" forState:0];
    }
}
#pragma mark- 点击事件
- (void)staffCellClick:(staffCellBlock)block
{
    _block = block;
}
- (IBAction)changeRoleClick:(UIButton *)sender
{
    LELog(@"%s---%d---改变角色",__func__,__LINE__);
    if (self.block) {
        _block(sender.tag,self.model);
    }
}
- (IBAction)fireClick:(UIButton *)sender
{
    LELog(@"%s---%d---解除",__func__,__LINE__);
    if (self.block) {
        _block(sender.tag,self.model);
    }
}

@end
